/**
 * 
 */
package com.heer.RD.projecthour.component;

import java.util.List;

import org.apache.wicket.ajax.markup.html.navigation.paging.AjaxPagingNavigator;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.markup.html.list.PageableListView;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.PropertyModel;
import org.springframework.jdbc.core.JdbcTemplate;

import com.heer.RD.projecthour.page.PersonStatPage;
import com.heer.RD.util.UtilsMisc;
import com.heer.joss.persistence.convention.ExpressionUtil;

/**
 * @author ZhaoZehui
 *
 */
public class UserProjCostPanel extends Panel {

	public UserProjCostPanel(String id, JdbcTemplate jt, String criteria) {
		super(id);
		
		String sql = ExpressionUtil.parse(PersonStatPage.userProjCostDetailSql, UtilsMisc.toMap("criteria", criteria));
		
		final List userProjDetailList = jt.queryForList(sql);

		final WebMarkupContainer userProjDetail = new WebMarkupContainer("userProjDetail");
		userProjDetail.setOutputMarkupId(true);
		PageableListView listview = new PageableListView("userProjDetailList", userProjDetailList, 10) {
			protected void populateItem(final ListItem detailItem) {
				
				detailItem.add(new Label("REG_DATE", new PropertyModel(detailItem.getModel(), "REG_DATE")));
				detailItem.add(new Label("HOUR_COST", new PropertyModel(detailItem.getModel(), "HOUR_COST")));
				detailItem.add(new MultiLineLabel("REG_MEMO", new PropertyModel(detailItem.getModel(), "REG_MEMO")));
			}
			
		};
		userProjDetail.add(listview);
		userProjDetail.add(new AjaxPagingNavigator("navigator", listview));
		userProjDetail.setVersioned(false);
		
		add(userProjDetail);
	}

}
